# Author: mosra <mosra@centrum.cz>
pkgname=magnum-examples
pkgver=dev
pkgrel=1
pkgdesc="Examples for the Magnum C++11/C++14 graphics engine"
arch=('i686' 'x86_64')
url="https://magnum.graphics"
license=('custom:Public Domain')
depends=('magnum' 'magnum-plugins' 'magnum-integration' 'magnum-extras' 'bullet' 'openal' 'glew' 'box2d' 'libdart' 'imgui-src')
makedepends=('cmake' 'ninja')
options=(!strip)
provides=('magnum-examples-git')

_rootdir=$startdir/../../

build() {
    mkdir -p "$_rootdir/build"
    cd "$_rootdir/build"

    cmake .. \
        -DCMAKE_BUILD_TYPE=Debug \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DIMGUI_DIR=/opt/imgui \
        -DWITH_ANIMATED_GIF_EXAMPLE=ON \
        -DWITH_ARCBALL_EXAMPLE=ON \
        -DWITH_AREALIGHTS_EXAMPLE=ON \
        -DWITH_AUDIO_EXAMPLE=ON \
        -DWITH_BOX2D_EXAMPLE=ON \
        -DWITH_BULLET_EXAMPLE=ON \
        -DWITH_CUBEMAP_EXAMPLE=ON \
        -DWITH_DART_EXAMPLE=ON \
        -DWITH_FLUIDSIMULATION2D_EXAMPLE=ON \
        -DWITH_FLUIDSIMULATION3D_EXAMPLE=ON \
        -DWITH_IMGUI_EXAMPLE=ON \
        -DWITH_MOTIONBLUR_EXAMPLE=ON \
        -DWITH_MOUSEINTERACTION_EXAMPLE=ON \
        -DWITH_OCTREE_EXAMPLE=ON \
        -DWITH_PRIMITIVES_EXAMPLE=ON \
        -DWITH_PICKING_EXAMPLE=ON \
        -DWITH_RAYTRACING_EXAMPLE=ON \
        -DWITH_SHADOWS_EXAMPLE=ON \
        -DWITH_TEXT_EXAMPLE=ON \
        -DWITH_TEXTUREDTRIANGLE_EXAMPLE=ON \
        -DWITH_TRIANGLE_EXAMPLE=ON \
        -DWITH_TRIANGLE_PLAIN_GLFW_EXAMPLE=ON \
        -DWITH_TRIANGLE_SOKOL_EXAMPLE=ON \
        -DWITH_TRIANGLE_VULKAN_EXAMPLE=ON \
        -DWITH_VIEWER_EXAMPLE=ON \
        -G Ninja
    ninja
}

package() {
    cd "$_rootdir/build"
    DESTDIR="$pkgdir/" ninja install

    # Install the UNLICENSE because Arch has no pre-defined license for Public
    # Domain
    install -D -m644 "${_rootdir}/COPYING" "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}
